<template>
	<view>
		<view class="index-top"></view>
			<view style="position: relative;z-index: 1;" class="dis-flex-column">
				<view class="mt30 px30">
					<view class="c-000 fs20">{{userInfo.realname?userInfo.realname:userInfo.username}}  {{getLevel()}}合伙人</view>
					<view class="mt20 dis-flex flex-align-center flex-between">
						<view class="fs14 c-000">任职公司：</view>
						<view class="fs14 c-000" v-if="userInfo.rztime">入职：{{userInfo.rztime?userInfo.rztime:''}}</view>
					</view>
					<view v-for="(item, index) in companyList" :key="index"  class="fs14 c-000 mt5">{{item}}</view>
				</view>
				<view class="px16 mt60">
					<view class="dis flex-align-center bg-fff br10 px16" style="height: 180rpx;margin-top: 15rpx;" v-for="(item, index) in newcompanyList" :key="index">
						<view class="c-999 fs15 fwb" style="padding-top: 15rpx;">团队{{index+1}} : {{item.name}}</view>
						<view class="flex ml20" style="margin-top: 15rpx;">
							<view class="dis-flex flex-between c-999" style="font-size: 26rpx;line-height: 26rpx;margin-bottom: 40rpx;">
								<view>【个人】</view>
								<view class="dis-flex flex flex-align-center">
									<view class="wd50">业绩: {{item.persontoatl}}</view>
									<view class="wd50">分红: {{item.personbonus}}</view>
								</view>
							</view>
							<view class="dis-flex flex-between c-999" style="font-size: 26rpx;line-height: 26rpx;">
								<view>【团队】</view>
								<view class="dis-flex flex flex-align-center">
									<view class="wd50">业绩: {{item.teamtoatl}}</view>
									<view class="wd50">分红: {{item.teambonus}}</view>
								</view>
							</view>
						</view>
					</view> 
					<!-- 
					<view class="dis-flex flex-align-center bg-fff br10 px16 mt30" style="height: 180rpx;">
						<view class="c-999 fs20 fwb">法务</view>
						<view class="flex ml20">
							<view class="dis-flex flex-between c-999" style="font-size: 26rpx;line-height: 26rpx;margin-bottom: 40rpx;">
								<view>【个人】</view>
								<view class="dis-flex flex-align-center flex">
									<view class="wd50">业绩: {{$api.delZero(messageData.fwpersontoatl)}}</view>
									<view class="wd50">分红: {{$api.delZero(messageData.fwpersonbonus)}}</view>
								</view>
							</view>
							<view class="dis-flex flex-between c-999" style="font-size: 26rpx;line-height: 26rpx;">
								<view>【团队】</view>
								<view class="dis-flex flex-align-center flex">
									<view class="wd50">业绩: {{$api.delZero(messageData.fwteamtoatl)}}</view>
									<view class="wd50">分红: {{$api.delZero(messageData.fwteambonus)}}</view>
								</view>
							</view>
						</view>
					</view>
					
					<view class="dis-flex flex-align-center bg-fff br10 px16 mt30" style="height: 180rpx;">
						<view class="c-999 fs20 fwb">金融</view>
						<view class="flex ml20">
							<view class="dis-flex flex-between c-999" style="font-size: 26rpx;line-height: 26rpx;margin-bottom: 40rpx;">
								<view>【个人】</view>
								<view class="dis-flex flex-align-center flex">
									<view class="wd50">业绩: 0.00000</view>
									<view class="wd50">分红: 0.00000</view>
								</view>
							</view>
							<view class="dis-flex flex-between c-999" style="font-size: 26rpx;line-height: 26rpx;">
								<view>【团队】</view>
								<view class="dis-flex flex-align-center flex">
									<view class="wd50">业绩: 0.00000</view>
									<view class="wd50">分红: 0.00000</view>
								</view>
							</view>
						</view>
					</view> -->
					
					<!-- <view class="dis-flex flex-align-center bg-fff br10 px16 mt30 space-around" style="height: 180rpx;">
						<view class="c-999 fs20 fwb">建资联动</view>
						<view class="c-999 fs20 fwb">法务联动</view>
						<view class="c-999 fs20 fwb">金融联动</view>
					</view> -->
					
					<!-- <view class="dis-flex flex-align-center bg-fff br10 px16 mt30" style="height: 180rpx;">
						<view class="c-999 fs20 fwb">报表</view>
						<view class="flex ml20">
							<view class="dis-flex flex-between c-999" style="font-size: 26rpx;margin-bottom: 40rpx;">
								<view class="">【团队】年/月(跳转后)显示总业绩</view>
							</view>
							<view class="dis-flex flex-between c-999" style="font-size: 26rpx;">
								<view class="">【成本】房租 水电费 物业费 社保 其它</view>
							</view>
						</view>
					</view> -->
					<view style="height: 40rpx;"></view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		computed: {
			...mapState(['userInfo','hasLogin'])
		},
		data() {
			return {
				companyList:[],
				newcompanyList:[],
				messageData:{},
			}
		},
		
		watch: {
		   userInfo: {
		     handler(newVal, oldVal) {
				 if(newVal.company) this.companyList = newVal.company.split('@#');
				 else this.companyList = [];
		     },
		     deep: true
		   },
		   hasLogin(val, old) {
		   	this.getMessage();
			this.GetCompany(); 
		   },
		},
		
		//页面相关事件处理函数--监听用户下拉动作
		onPullDownRefresh() {
			this.getMessage();
			this.GetCompany(); 
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1500);
		},
		
		onLoad(option) {
			if(this.hasLogin){
				if(this.userInfo.company) this.companyList = this.userInfo.company.split('@#');
				 else this.companyList = [];
				 
				this.getMessage(); 
				
				this.GetCompany(); 
			}
		},
		
		onTabItemTap(){
			if(!this.hasLogin) this.$api.openWindow('/pages/login/login');
		},
		
		methods: {
			getMessage(){
				this.$http.post(this.$config.UrlGetWork, {
				}, {
					header: {
						'content-type': 'application/json'
					}
				}).then((res) => {
					this.messageData = res.data || {};
				})
			},
			
			GetCompany(){
				
				this.$http.post(this.$config.UrlGetCompany, {
				}, {
					header: {
						'content-type': 'application/json'
					}
				}).then((res) => {
					
					this.newcompanyList = res.data || {};
				})
			},
			
			
			getLevel(){
				if(!this.hasLogin) return '';
				if(this.userInfo.group_id == 1) return '初级';
				if(this.userInfo.group_id == 2) return '中级';
				if(this.userInfo.group_id == 3) return '高级';
				return '';
			},
		}
	}
</script>

<style>
	.index-top {
		width: 100%;
		height: 100%;
		background-image: url(~@/static/images/login-bg.png); 
		background-size: 100% 100%;
		position: fixed;
		top: 0rpx;
	}
	
	.userContent {
		width: 100%;
	
		.list {
			width: 90%;
			height: 200rpx;
			margin: 80rpx auto 20rpx;
			line-height: 200rpx;
			background-color: #fff;
			border-radius: 20rpx;
			text-align: center;
			display: flex;
			justify-content: space-around;
			align-items: center;
			font-size: 46rpx;
		}
	}
</style>
